<template>
  <view class="news-list-page">
    <view class="news-list">
      <NewsCard 
        v-for="(item, index) in newsList" 
        :key="item.nID || index" 
        :item="item" 
        :isAd="item.isAd"
        @click="handleItemClick(item)"
		
      ></NewsCard>
    </view>
  </view>
</template>


<script>
import NewsCard from "/components/NewCardView.vue";

export default {
  components: {
    NewsCard
  },
  data() {
    return {
      newsList: [
        {
          nID: "1",
          title: "时隔十年，沪指重返4000点，券商：牛市格局已形成",
          isTop: true,
          author: "扬子晚报",
          comment: 42,
          time: "2025.10.28",
          image: "https://picsum.photos/200/140?random=1"
        },
        {
          nID: "2",
          title: "2022年以来最大规模人员调整：亚马逊计划裁员3万人",
          isTop: true,
          author: "DoNews",
          comment: 46,
          time: "2025.10.28",
          image: "https://picsum.photos/200/140?random=2"
        },
        // 带图广告（广告标签在图片左下角）
        {
          nID: "ad1",
          title: "年度钜惠：新款5G手机直降800元，限量抢购中",
          isAd: true,
          author: "科技数码旗舰店",
          time: "2025.10.28 10:00",
          adImage: "https://picsum.photos/200/140?random=10"
        },
        {
          nID: "3",
          title: "黄金跌破4000美元！专家：短期或继续震荡",
          isTop: false,
          author: "齐鲁壹点",
          comment: 5,
          time: "2025.10.28",
          image: "https://picsum.photos/200/140?random=3",
          tags: ["财经", "贵金属"]
        },
        {
          nID: "ad2",
          title: "冬季旅游特惠：云南双飞6日游仅需1999元",
          isAd: true,
          author: "环球旅行社",
          time: "2025.10.28 09:30",
          adImage: "https://picsum.photos/200/140?random=11"
        }
      ]
    };
  },
  methods: {
    handleItemClick(item) {
      if (item.isAd) {
        console.log("点击广告：", item.title);
      } else {
        console.log("点击新闻：", item.nID);
        uni.navigateTo({
          url: `/pages/news-detail/detail?nid=${item.nID}`
        });
      }
    }
  }
};
</script>

<style scoped>
.news-list-page {
  background-color: #f5f5f5;
  min-height: 100vh;
}

.page-header {
  background-color: #fff;
  padding: 28rpx 20rpx;
  border-bottom: 1rpx solid #eee;
}

.page-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
}

.news-list > :last-child .news-card {
  border-bottom: none;
}
</style>